﻿using System.Threading.Tasks;

namespace Cemit.NetFramework
{
    public class PolyClient
    {
        public bool IsConnected => socket != null && socket.IsConnected;
        
        protected PolySocket socket;

        public async Task<AsyncReport> Connect(string ip, int port)
        {
            if (socket != null && (socket.IsConnected || socket.IsConnecting))
            {
                return new AsyncReport(false, "连接失败：服务器已连接或已经开始进行连接！");
            }

            socket = PolyNetwork.CreateSocket();

            return await socket.Connect(ip, port);
        }
    }
}